package main;

public class Liczba {

	private int value;
	
	public Liczba(int value) throws IllegalArgumentException{
		if(value < 0) throw new IllegalArgumentException("value is < 0, not Natural number");
		this.value = value;
	}
	
	public void set(int value) throws IllegalArgumentException{
		if(value < 0) throw new IllegalArgumentException("value is < 0, not Natural number");
		this.value = value;
	}
	
	public int get() {
		return value;
	}
	
	public String get(int radix) throws IllegalArgumentException{
		if(radix < 2 || radix > 16) throw new IllegalArgumentException("radix is out of <2,16> range");
		return Integer.toString(value, radix);
	}

	@Override
	public boolean equals(Object arg) {
		if(this == arg) return true;
		if(arg == null) return false;
		if(this.getClass() != arg.getClass()) return false;
		
		if(this.value == ((Liczba)arg).value) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return value;
	}
}
